package com.globalwave.datasync.convertor.impl;

import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Types;

import com.globalwave.datasync.ConvertorInf;

public class BigDecimal2Date implements ConvertorInf {
	
	@SuppressWarnings("deprecation")
	@Override
	public Object valueOf(Object input) {
		Integer date = null ;
		if (input instanceof BigDecimal) {
			date = ((BigDecimal)input).intValue() ;
		}else if (input instanceof Integer) {
			date = (Integer)input ;
		} else {
			return null ;
		}
		
		return new Date(date/10000 - 1900, (date%10000)/100 - 1, date%100 );
	}

	@Override
	public int outputType() {
		return Types.DATE;
	}
}
